﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Chat
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Chat</h2>
    <script src="../../Scripts/amcharts.js" type="text/javascript"></script>
    <script src="../../Scripts/serial.js" type="text/javascript"></script>
    <script src="../../Scripts/black.js" type="text/javascript"></script>
    <style type="text/css">
        #chartdiv
        {
            width: 100%;
            height: 500px;
            font-size: 11px;
            background-color: Gray;
        }
    </style>
    <input type="button" id="btnGet" value="Get data" onclick="GetData();" />
    <div id="chartdiv">
    </div>
    <script type="text/javascript">

        function GetData() {
            $.ajax({
                type: 'POST',
                contentType: 'application/json;',
                url: '../../Home/GetData',
                data: '',
                dataType: 'json',
                success: function (ctx) {
                    var str = ctx;
                    //var json = eval("(" + str + ")");
                    var chart = AmCharts.makeChart("chartdiv", {
                        "type": "serial",
                        "theme": "none",
                        "dataProvider": ctx,
                        "startDuration": 1,
                        "graphs": [{
                            "balloonText": "<b>[[category]]: [[value]]</b>",
                            //"colorField": "color",
                            "fillAlphas": 0.9,
                            "lineAlpha": 0,
                            "type": "column",
                            "valueField": "CostTime"
                        }],
                        "chartCursor": {
                            "categoryBalloonEnabled": false,
                            "cursorAlpha": 0,
                            "zoomable": false
                        },
                        "categoryField": "FunctionName",
                        "categoryAxis": {
                            "gridPosition": "start",
                            "labelRotation": 45
                        },
                        "exportConfig": {
                            "menuTop": "20px",
                            "menuRight": "20px",
                            "menuItems": [{
                                "icon": '/lib/3/images/export.png',
                                "format": 'png'
                            }]
                        }
                    });
                },
                error: function (ctx) {
                    var err = eval('(' + ctx.responseText + ')');
                    alert("Error:" + err.Message);
                }
            });
        }
    </script>
</asp:Content>
